//
//  HJCustomerReceptionViewCell.m
//  GAMCAfterSales
//
//  Created by 贺佳 on 2018/5/17.
//  Copyright © 2018年 glendale. All rights reserved.
//

#import "HJCustomerReceptionViewCell.h"

@interface HJCustomerReceptionViewCell()
/**
 车型类型数组
 */
@property(nonatomic,strong)NSArray*carTypeAry;
/**
 车系类型数组
 */
@property(nonatomic,strong)NSArray*carSeriesAry;
//
@end
@implementation HJCustomerReceptionViewCell

UITablecellM(@"HJCustomerReceptionViewCell")
-(NSArray *)carSeriesAry
{
    if (!_carSeriesAry) {
         NSArray*carTypeAry=[self readershuDICimform][@"SERIES"];
        _carSeriesAry=carTypeAry;
    }
    return _carSeriesAry;
}
-(NSArray *)carTypeAry
{
    if (!_carTypeAry) {
          NSArray*carTypeAry=[self readershuDICimform][@"CONFIG"];
        _carTypeAry=carTypeAry;
    }
    return _carTypeAry;
}
-(void)setUI{
//    self.selectionStyle=UITableViewCellSelectionStyleNone;
    for (int i=0; i<7; i++) {
        UILabel *titlelabel = [[UILabel alloc]init];
        titlelabel.backgroundColor = [UIColor clearColor];
        titlelabel.textColor = [UIColor grayColor];
        titlelabel.numberOfLines=0;
        titlelabel.font = [UIFont fontWithName:@"ArialMT" size:14];
        [titlelabel setTextAlignment:NSTextAlignmentCenter];
        [self.contentView addSubview:titlelabel];
    }
}
-(void)setCustomerReceptionModel:(HJCustomerReceptionModel *)customerReceptionModel
{
    _customerReceptionModel=customerReceptionModel;
    int i =0;
    for (UILabel*label in self.contentView.subviews) {
        switch (i) {
            case 0:
                
                break;
            case 1:
                label.text=customerReceptionModel.LICENSE;
                break;
            case 2:
                label.text=customerReceptionModel.VIN;
                break;
            case 3:
            {
                for (NSDictionary*dict in self.carSeriesAry) {
                    if ([dict[@"SERIES_CODE"] isEqualToString:customerReceptionModel.SERIES]) {
                        label.text=dict[@"SERIES_NAME"];
                        break;
                    }
                }
            }

                break;
            case 4:
            {
                for (NSDictionary*dict in self.carTypeAry) {
                    if ([dict[@"MODEL_CODE"] isEqualToString:customerReceptionModel.MODEL]) {
                        label.text=dict[@"CONFIG_NAME"];
                        break;
                    }
                }
                
            }
                break;
            case 5:
                label.text=customerReceptionModel.OWNER_NAME;
                break;
            case 6:
             label.text=customerReceptionModel.MOBILE;
                break;
           
                
            default:
                break;
        }
        i++;
    }
}
-(NSMutableDictionary *)readershuDICimform
{
    NSMutableDictionary *dic=[NSMutableDictionary dictionary];
    NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *path=[paths objectAtIndex:0];
    NSString *str=[path stringByAppendingPathComponent:@"Dic.text"];
    dic=[NSMutableDictionary dictionaryWithContentsOfFile:str];
    //nslog(@"%@",dic);
    return dic;
}
-(void)setIndexPath:(NSIndexPath *)indexPath
{
    _indexPath=indexPath;
    UILabel*label=self.contentView.subviews[0];
    label.text=[NSString stringWithFormat:@"%zd",indexPath.row+1];
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat w=self.contentView.mj_w/self.contentView.subviews.count;
    int i=0;
    for (UIView*subView in self.contentView.subviews) {
        subView.frame=CGRectMake(i*w, 0, w, self.contentView.mj_h);
        i++;
    }
}
@end
